﻿using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Xml.Serialization;
using PrearrangedChaos.AgileZen.Service.Rest;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    /// <remarks/>
    [DebuggerStepThrough()]
    [XmlTypeAttribute(AnonymousType = true)]
    [XmlRootAttribute(ElementName = "project", Namespace = "", IsNullable = false)]
    [ZenRestRequest("projects/{ProjectId}", "projects")]
    public partial class Project : ProjectUpdater, IProject
    {
        private IInvite[] _invites;
        private IUser[] _members;
        private IProjectMetrics _metrics;
        private IPhase[] _phases;
        private IRole[] _roles;

        /// <remarks/>
        [XmlElement(ElementName = "createTime")]
        public DateTime CreateTime { get; set; }

        public bool CreateTimeSpecified { get { return false; } }

        [XmlArrayItemAttribute("invite", IsNullable = false)]
        [XmlArray(ElementName = "invites")]
        public Invite[] InvitesXmlElement
        {
            get { return _invites as Invite[]; }
            set { _invites = value; }
        }

        [XmlIgnore]
        public ReadOnlyCollection<IInvite> Invites
        {
            get { return new ReadOnlyCollection<IInvite>(_invites ?? new Invite[0]); }
        }

        public bool InvitesXmlElementSpecified { get { return false; } }

        [XmlArrayItemAttribute("user", IsNullable = false)]
        [XmlArray(ElementName = "members")]
        public User[] MembersXmlElement
        {
            get { return _members as User[]; }
            set { _members = value; }
        }

        [XmlIgnore]
        public ReadOnlyCollection<IUser> Members
        {
            get { return new ReadOnlyCollection<IUser>(_members ?? new User[0]); }
        }

        public bool MembersXmlElementSpecified { get { return false; } }

        [XmlIgnore]
        public IProjectMetrics Metrics
        {
            get { return _metrics; }
            set { _metrics = value; }
        }

        [XmlElement(ElementName = "metrics")]
        public ProjectMetrics MetricsXmlElement
        {
            get { return _metrics as ProjectMetrics; }
            set { _metrics = value; }
        }

        public bool MetricsXmlElementSpecified { get { return false; } }

        [XmlArrayItemAttribute("phase", IsNullable = false)]
        [XmlArray(ElementName = "phases")]
        public Phase[] PhasesXmlElement
        {
            get { return _phases as Phase[]; }
            set { _phases = value; }
        }

        [XmlIgnore]
        public ReadOnlyCollection<IPhase> Phases
        {
            get { return new ReadOnlyCollection<IPhase>(_phases ?? new Phase[0]); }
        }

        public bool PhasesXmlElementSpecified { get { return false; } }

        [XmlArrayItemAttribute("role", IsNullable = false)]
        [XmlArray(ElementName = "roles")]
        public Role[] RolesXmlElement
        {
            get { return _roles as Role[]; }
            set { _roles = value; }
        }

        [XmlIgnore]
        public ReadOnlyCollection<IRole> Roles
        {
            get { return new ReadOnlyCollection<IRole>(_roles ?? new Role[0]); }
        }

        public bool RolesXmlElementSpecified { get { return false; } }

    }
}